package xuesm.strategy.promotion;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: xuesm
 * @Description: 活动策略工厂
 * @Date: Create in 13:03 2019/4/12
 */
public class PromotionStrategyFactory {

	private static Map<String, PromotionStrategy> PROMOTION_STRATEGY_MAP = new HashMap<>();


	static {
		PROMOTION_STRATEGY_MAP.put(PromotionKey.COUPON, new CouponStrategy());
		PROMOTION_STRATEGY_MAP.put(PromotionKey.CASHBACK, new CashBackStrategy());
		PROMOTION_STRATEGY_MAP.put(PromotionKey.GROUP, new GroupByStrategy());
		PROMOTION_STRATEGY_MAP.put(PromotionKey.DEFAULT, new EmptyStrategy());
	}

	private final static  PromotionStrategy NON_PROMOTION = new EmptyStrategy();

	public static PromotionStrategy getPromotionStrategy(String promotionKey){
		PromotionStrategy strategy = PROMOTION_STRATEGY_MAP.get(promotionKey);
		return strategy == null ? NON_PROMOTION: strategy;
	}


	private interface PromotionKey{
		String COUPON = "COUPON";
		String CASHBACK = "CASHBACK";
		String GROUP = "GROUP";
		String DEFAULT = "DEFAULT";
	}
}
